"use client"
import { startTransition } from 'react'
import { useRouter } from 'next/navigation'

export default function ErrorBoundary({
    error,
    reset
}: {
    error: Error,
    reset: () => void
}) {
    const router = useRouter();
    const handleRetry = () => {
        startTransition(() => {
            reset();
            // 重新加载当前页面
            router.refresh();
        });
    };
    return (
        <div>
            <h2>{error.message}</h2>
            <button onClick={handleRetry}>Please try again</button>
        </div>
    )
}
